Python 2 & 3 compatibility

This code passes tests for the following versions of Python: 2.6, 2.7, 3.2, 3.3, 3.4
It is not compatible with 2.5 or lower
It has not yet been tested on 3.1

Closes issue #4