Bedard pitches Pirates to 4-2 win over Royals