Fixing runtime errors for Python 3

- Hopefully we can make this compatible with both Python 2.7.2 and 3.x
with any luck!