remove usage of tempfile.mkstemp because it was too easy to leave open file handles laying around