The EU has agreed to implement levies on energy firms which are benefiting from soaring gas prices.