imgtool.py: Fix some errors in ecdsa key generation

There are two easy to fix problems with the ecdsa key generation code.

Signed-off-by: David Brown <david.brown@linaro.org>
diff --git a/scripts/imgtool/keys.py b/scripts/imgtool/keys.py
index fc90f9e..e81f6f6 100644
--- a/scripts/imgtool/keys.py
+++ b/scripts/imgtool/keys.py
@@ -84,7 +84,7 @@
 
     def export_private(self, path):
         with open(path, 'wb') as f:
-            f.write(key.to_pem())
+            f.write(self.key.to_pem())
 
     def emit_c(self):
         vk = self.key.get_verifying_key()