emulate lua_tointegerx for lua 5.1/luajit