X-ray micro-tomography is used to image the pore-scale configurations of fluid in a rock saturated with three phases - brine, oil and gas - mimicking a subsurface reservoir, at high pressure and temperature. We determine pore occupancy during a displacement sequence that involves waterflooding, gas injection and water re-injection. In the water-wet sample considered, brine occupied the smallest pores, gas the biggest, while oil occupied pores of intermediate size and is displaced by both water and gas. Double displacement events have been observed, where gas displaces oil that displaces water or vice versa. The thickness of water and oil layers have been quantified, as have the contact angles between gas and oil, and oil and water. These results are used to explain the nature of trapping in three-phase flow, specifically how oil preferentially traps gas in the presence of water.