Use custom tempfile to avoid ruby 1.8-related test failures

Tempfile in ruby 1.8.7 calls `File.exist?()`, which we set a stub on.
For reasons that are not clear, this does not consistently fail. In any
case, using a custom temporary file implementation resolves the issue.