How does biodiesel have so much energy density?
Where you go wrong is in thinking that cooking oil has less energy density than biodiesel. The Wikipedia page for biofuel energy content list a number of different types of fuel. Along with a long list of other fuels, it lists the following:

Fuel Type   Specific energy (MJ/kg) Energy Density (MJ/L)
Methanol    19.9 – 22.7             15.9
Fat         37.656                  31.68
Sunflwr oil 39.49                   33.18
Olive oil   39.25 - 39.82           33 - 33.48
Biodiesel   37.8                    33.3 – 35.7
Diesel      48.1                    40.3


As you can see, both the specific energy (MJ/kg) and energy density (MJ/l) are about the same as biodiesel and close to those of ordinary diesel fuel. To convert the oil into biodiesel, some methanol is usually added, but that does not increase the energy density.