Factor out tempfile creation and use TMPDIR
Merge pull request #37 from jeroenk/tmpdir

Factor out tempfile creation and use TMPDIR