Use mkstemp instead of NamedTemporaryFile because the latter deletes file on close on Windows.