Two-dimensional (2D) layered materials have many features suitable for optoelectronic devices, but poor quality substrates can degrade optical properties. By encapsulating a monolayer semiconductor in layers of atomically-thin hexagonal boron nitride, a nearly pristine environment can be achieved free from surface roughness and defects of typical substrates. Emission linewidths from encapsulated layered heterostructures are improved by an order of magnitude, which is important for assembling these materials into integrated photonic devices designed to reveal exotic coherent light-matter interactions.