Updating to work with Python 3

Python 3 needs the files to be opened as 'write bytes'