Python3 support

I know that this is not the first patch on this subject :) But it passes the current test suite, and makes minimal changes to the original code. And it will be transparent for the client applications,  do not need convert  the keys to bytes for example.