Thermodynamic performance of fuel cells and comparison with heat engines