Energy recovery from gas flaring