The UK economy grew in August after it was flat in the previous two months, according to the latest official figures.