Optimize: Tempfile management

`Tempfile.open` has some finalizer and unlinking overhead that was don't actually use since we close the file right away. `Tempfile.create` was added in Ruby 2.1 to help, but it isn't widely available yet. Copy pasta some of its internals here.