Better tmpfile handling

````
o Do close/unlink operations in an ensure block
o Unlink the file when done.
   If we don't unlink explicitly it will be unlinked when the tempfile
   object is GCed. In some environments with tuned GC we might end up
   with a lot of files in /tmp.
````