buffer: add a base function for buffer readInt/writeInt