Added to_buffer() method