Fix infinite loop during taking pictures if flash is not used