diff --git a/app.py b/app.py
index d010bf9c87f792ffe2f9e4c537f72bddb877f9bf..f31025b4c494169fc83b5bc16ff6a1b043c06da1 100644
--- a/app.py
+++ b/app.py
@@ -243,8 +243,11 @@ def hpgl (id):
     svg = ascii2svg(ascii_input, params['weight'])
 
     # store as a temporary file
-    (svg_file, svg_path) = tempfile.mkstemp()
-    svg_file.write(svg)
+    (svg_file, svg_path) = tempfile.mkstemp('.svg')
+
+
+    with open(svg_file, 'w') as svg_handle:
+        svg_handle.write(svg)
 
     # transform to hpgl
     hpgl = svgToHPGL(svg_path)