Py2&3 port

Initial port is done. Tests are passing against 2.7 and 3.3 using six for almost all incompatibilities. Still some code duplication to remove.