Selective growth of layered perovskites for stable and efficient photovoltaics