Better Python3 compatibility

Avoid "2to3" by writing coe that works in both Python2 (2.6+) and
Python3. Not sure about the exception handling though.