Preparation for python3 support.

Used 2to3 (2to3 --output-dir=python3-version/mycode -W -n
python2-version/mycode) and manual editing. Hints via pyCharm IDE.