add save and logfile output to modimage
no need to calculate W when flag=0
support multiple size of images
change param C to 40
bugfix of save params
new checkin of samplegen
bugfix in modimage.m