fix TypeError when using python 3