Make library compatible with Python2 and Python3