Apply some syntax changes accepted by Python 2.7 as well as Python 3

Use 2to3 to make some syntax changes for Python 3 that are also accepted
by Python 2.7. This will break compatibility with 2.6.

- Use except ... as
- Use print() as a function
- Use 'in' instead of has_key
- Use repr instead of backticks
- Use '.' for relative imports
- Replace '<>' with '!='