In order to create RAW-files for images in MATLAB, use the FWRITE function with 'uint8' or 'uint16' as the precision specifier, as in the example below (which creates a black image (all zeros) of size 100x100
cmodel=(zeros(300,100,1));
fid=fopen('blackimage.raw','w+');
cnt=fwrite(fid,cmodel,'uint8');
fclose(fid);