Modified file write parameters to handle python 3