Optimal Planning and Operation of Power to Gas Energy Hubs in Transitioning Electricity Systems