Python 3.x compatibility refactoring.

This pull request implements some changes which make `purl` compatible with Python 2.6 through 3.2 (and I assume also 3.3).