Attempt to rewrite tempfile monkey patch