Weak gravitational lensing has emerged as a powerful technique to map the dark matter in the universe and to measure cosmological parameters. It is based on the small distortions that weak lensing induces in the shapes of background galaxies by intervening large scale structures. This technique is unique in astronomy, as it directly provides the distribution of mass, as opposed to light, without any assumptions about the physical state of matter. After decribing the principles of weak lensing and summarising the status of the field, I will describe the high-precision methodology required to extract a mass map from deep optical images. In particular, I will describe a new method based on the decomposition of the shapes of galaxies into a series of shape components or 'shapelets'. I will describe its performance for weak lensing and will discuss its other applications in astronomy, such as deconvolution, photometry, de-projection, galaxy morphology, and image simulations.