add buffer copy function that is used for error-diffusion.