write back to buffer