Fixed exception handling for Python 3.x

Code is now PEP 3110 compatible.
Python 3.0 compatibility, print.
Python 2 and Python 3 compatibility fixes