In this paper we present 3D measurements of the energy deposition by a clinical carbon ion beam in a water phantom. Conventionally, these measurements are performed with an array of ionization chambers and used for quality assurance. The spatial resolution is typically not better than 5 mm. We used the GEMPix, a gaseous detector with a highly pixelated readout and much better spatial resolution. The GEMPix was obtained by coupling a triple Gas Electron Multiplier (GEM) to a quad Timepix ASIC with 512x512 pixels and 55μm pitch. The Bragg curve, 2D images of the beam and a 3D reconstruction of the energy deposition are obtained from a single depth scan performed in approximately 15 minutes. A separate linearity check was also performed. The detector response is well linear and the measured Bragg curve is very smooth with uncertainties of a few percent. 3D energy deposition measurements in a water phantom with the GEMPix provide better spatial resolution than conventional devices. Systematic differences in the Bragg curve in comparison to the reference one are still too large for clinical use but work on several improvements is on-going.