fix casting issue for py2