i have the same problem with my Samsung WB850f camera,
have you tried getting another battery and seeing if the battery that you are using is drawing to much charge and when it happens on low charge or full charge. If its fine on full charge and as the battery drains then it happens it happens then its the battery. The other option is issue in the software that is causing the setting to change while you trying to take a photo