Added support for Python 3

Using six for compatibility between Python 2 and Python 3 in the same codebase.