Python 3 support for CPT

Fixed some problems in dual compatibility with Python 2 and Python 3.
Extends Pull Request #56. Completes Issue #41.