Updated to work in both Python 2 and 3

Just a couple of small changes to make the code conform to both Python 2 and 3