rudimentary SAM writing

This is mostly intended for debugging... if you print SAM for
processing, you need professional help.