Fix some bugs with pyside and python 2