Supporting for Python 2 and 3 with the same code base

resolve #948