Added compatibility with python 3