Patch to make it work with python 3.4

Taken from faucamp#39
Unit test won't work, a huge work is needed to completely port to python 3.
But at least we have something working.