use faster method for rewriting bam