Fix the buffer handling logic so that write_impl is always called with