A common problem in loose terrain is the sliding and skidding of your front wheel, which can lead to a crash known as a washout. To prevent this, move your weight forward to help the front wheel regain traction. In the opposite case, when you feel your back wheel starting to skid, let off on the rear brakes and you will usually recover.
In really loose terrain; such as deep sand, you need to position your body so that the bike is relatively upright. This is done by leaning your weight in the direction of your turn, while bending your knees to the side in order to keep the bike upright.