improved error checking for BAM and SAM formats