The UK economy grew in August after two months of flatlining earlier in the summer, official figures showed on Friday.