added missing implementation of copyBufferToImage