Converted script for Python 3

Edited the script to work with Python3. Changes made

- Using Pillow instead of PIL. So the import is now:
  from PIL import Image

- Updated urllib import for Python3:
  import urllib.request
  And change the method calls to start with urllib.request.****

- Edited how the script handles the opening and writing of the file and
  also how it deals with the file data. Explicitly using binary mode and
  using using with open statements to clean up file handling. Also had to
  define 'repeated' as a bytes literal to allow the concatination with the
  file data:
  repeated = b''