Add write and read functions in buffer.lua