wrap tempfile.mkstemp to work on windows

The path returned by tempfile.mkstemp is encoded in system locale,
since we need to pass it through rpc, we need it to be encoded in UTF-8