Pirates rally past Padres thanks to late error