buffer: implement copy