function nothing = myimwrite(myvar);
fid=fopen("myvaroutput.pgm","w");
fprintf(fid,"P5\n%d\n%d\n%d\n",size(myvar),255);
%%%fwrite(fid,myvar,"UINT8");
fwrite(fid,myvar,"uchar");
fflush(fid)
eval(system("cjpeg myvaroutput.pgm > myvaroutput.jpg"));

