Samtools can be used to convert between sam and bam:
-b indicates that the input file will be in BAM format
-S indicates that the stdout should be in SAM format
samtools view -sB thing.bam > thing.sam
And to convert between sam and bam:
samtools view thing.sam > thing.bam
samtools ...