Python3 Compatibility

Switched to the python3 syntax for printing and exception handling, so that this can be used in python3.