Potential automorphy for certain Galois representations