Can this be done with `tempfile` instead?  i.e. `fileobj = tempfile.NamedTemporaryFile()`?  I think that would allow you to avoid the garbage collection steps.  Perhaps there is a reason that is not possible, though?