slightly more robust tempfile creation