rem: fwrite(image->data[0], 1, image->width * image->height, f); fwrite(image->data[1], 1, image->width * image->height, f); fwrite(image->data[2], 1, image->width * image->height, f); if (image->data[3]) fwrite(image->data[3], 1, image->width * image->height, f);
add: fwrite(image->data, 1, image->width * image->height * channels, f);
context: dumpRImage(char *path, RImage *image){    FILE *f;    f = fopen(path, "w");    if (!f) {	wsyserror(path);	return;    }    fprintf(f, "%02x%02x%1x", image->width, image->height,	    image->data[3]!=NULL ? 4 : 3);    fwrite(image->data[0], 1, image->width * image->height, f);    fwrite(image->data[1], 1, image->width * image->height, f);    fwrite(image->data[2], 1, image->width * image->height, f);    if (image->data[3])	fwrite(image->data[3], 1, image->width * image->height, f);    if (fclose(f) < 0) {	wsyserror(path);    }}