Clean up some comments.  Add const where appropriate.  Allow selection
of different config and output file names on command line.

Remove memcpy: delay shfree until after image is written.