Updated to make compatible with Python3

After this edit, tests pass both in python 2 and python 3. I haven't looked at this app's tests, but I assume that means it didn't break anything. (It shouldn't, given that the changes are relatively minor anyway)