fix hex parsing for py3