fix write error in py3