Python 2/3 compatibility done

And remove all trailing spaces