Write data into buffer