add BOM if useBOM flag is true