Port to Python 3.3

This patch ports the whole code base to Python 3, including all the unit
tests.