Fix type annotation on write_buffer