Port python module and python code generator to be compaitable with python 3.