Fix test failures on Windows

See https://docs.python.org/2/library/tempfile.html#tempfile.NamedTemporaryFile
for details (the temp file cannot be opened a second time on Windows).