Modified to support Python3

Not backward compatible with python 2.x