Use crossplatform tempfile

This will work on windows as well.