Ethanol has less energy when only looking at the fuel alone. However, we don't burn fuel alone. It's an air/fuel mixture by mass. Thus, you have to consider stoichiometry. When factored for stoich AFR, ethanol produces more energy than gasoline.
Gasoline = 20,012 BTU/lb ÷ 14.7 AFR = 1,361...