mkstemp blocks writing to the file on windows. Instead, create and destroy a tempfile in order to get its path and filename.