imgtool: add option to export public PEM

Update `getpub` with new `lang` option, "pem", which allows exporting a
public key as a PEM file. This can later be distributed to be used for
encrypting an image, and gets away with having to use openssl for this
step.

Signed-off-by: Fabio Utzig <utzig@apache.org>
diff --git a/scripts/imgtool/keys/general.py b/scripts/imgtool/keys/general.py
index 8e3c65b..77caf5d 100644
--- a/scripts/imgtool/keys/general.py
+++ b/scripts/imgtool/keys/general.py
@@ -37,6 +37,9 @@
                 indent="    ",
                 file=file)
 
+    def emit_public_pem(self, file=sys.stdout):
+        print(str(self.get_public_pem(), 'utf-8'), file=file, end='')
+
     def emit_private(self, minimal, file=sys.stdout):
         self._emit(
                 header="const unsigned char enc_priv_key[] = {",