Where are the losses in an inverter-type portable generator?
First, you are assuming that just because the engine is rated for 4 kW it is actually run at 4 kW.

Second, 3 kW electrical power out, converted to your AC standard and probably regulated, from 4 kW in doesn't sound so bad at all.  That's 75% effiecient from the shaft to the outlet, with several conversions in between.  There is the mechanical to electrical conversion of the generator or alternator itself, probably some sort of DC conversion, then a inverter stage that makes presumably nice AC like you get in your house.  Even if there are only 2 conversions from shaft to outlet and the losses are equal per conversion, each would have to be 87% to acheive 75% overall.  With three equal conversion each would need to be 91%.  Sounds like you're getting quite reasonable performance for a portable generator.

Now compare that to the losses in converting gasoline to shaft rotation and you'll see none of them matter.  The gasoline to shaft conversion is probably a order of magnitude less efficient than the 75% you are quoting from shaft to outlet.  You are looking at the wrong end of the generator unit to find gross inefficiency.