The key to preventing fog is keeping your warm, moist breath from hitting your lenses. This means making sure that your masks fits tightly along the contours of your nose/cheeks.
Make sure the bar is moulded to your face (if it has one). You can even tape it to your face, or tuck the edges under your glasses. Other remedies such as soapy water may help, but it may leave a blurry film on your glasses.