Fix use of mkstemp

tempfile.mkstemp() returns a tuple (fd, filename), not just filename. Fixed to use the filename.