I added necessary changes to allow the python script to run in python3, while being backwards compatible with 2.7.