In dielectric cavities with a rotational symmetry, whispering gallery modes (WGMs) with an extremely long lifetime (that is, a very high Q factor) can be formed by total internal reflection of light around the rim of the cavities. The ultrahigh Q factor of WGMs has enabled a variety of impressive photonic systems, such as ultralow threshold microlasers(1-3), biosensors with unprecedented sensitivity(4,5) and cavity optomechanical devices(6). However, the isotropic emission of WGMs, which is due to the rotational symmetry, is a serious drawback in applications that require directional light sources. Considerable efforts have thus been devoted to achieving directional emission by intentionally breaking the rotational symmetry(7-9). However, all of the methods proposed so far have suffered from substantial Q-spoiling. Here, we show how the mode properties of dielectric whispering gallery cavities, such as the Q factor and emission directionality, can be tailored at will using transformation optics. The proposed scheme will open a new horizon of applications beyond the conventional WGMs