The best thing to do for that is just use your legs as shocks a bit and absorb the rocks and roots. Just relax your knees and let the bike hop around but try to keep your body level. If your legs are stiff your feet tend get thrown off your pedals more.