Methods for stabilizing perovskites