Hamels goes 8 innings, Phillies beat Diamondbacks