Massive changes from SF 589982 (tempfile.py rewrite, by Zack
Weinberg).  This changes all uses of deprecated tempfile functions to
the recommended ones.
diff --git a/Lib/mimetools.py b/Lib/mimetools.py
index f97787a..f1e20d4 100644
--- a/Lib/mimetools.py
+++ b/Lib/mimetools.py
@@ -202,8 +202,8 @@
     pipe.close()
 
 def pipethrough(input, command, output):
-    tempname = tempfile.mktemp()
-    temp = open(tempname, 'w')
+    (fd, tempname) = tempfile.mkstemp()
+    temp = os.fdopen(fd, 'w')
     copyliteral(input, temp)
     temp.close()
     pipe = os.popen(command + ' <' + tempname, 'r')