UK factory output hits a two-year high as growth in manufacturing faces challenges from rising costs of energy and transport.