change outfile extension to reflect output format

when input format and output format of alignments are different, the current code uses the wrong extension in the output files.