Python 3 compatibility.

Make the minimum modifications to get compatible with python 3 without losing python 2.7