Breaking an i32 into four bytes.
printf "0: %.8x" $int | xxd -r -g0 >>file
Learn printf kids, then you won't need to steal #howto's from #stackoverflow like your old man does.
Credit:
https://stackoverflow.com/questions/9955020/how-to-write-integer-to-binary-file-using-bash