Polaron and bipolaron formation in a cubic perovskite lattice