Этот небольшой пример будет читать 32-битное целое число со знаком из файла и печатать его значение.
-- convert bytes (little endian) to a 32-bit two's complement integer
function bytes_to_int(b1, b2, b3, b4)
if not b4 then error("need four bytes to convert to int",2) end
local n = b1 + b2*256 + b3*65536 + b4*16777216
n = (n > 2147483647) and (n - 4294967296) or n
return n
end
local f=io.open("test.bin") -- contains 01:02:03:04
if f then
local x = bytes_to_int(f:read(4):byte(1,4))
print(x) --> 67305985
end