fixed a bug in bam writer