Also, modern refining technology allows a greater percentage of a barrel of oil to be made into gasoline, and the low-sulfur mandate has also added to the cost of production.
Diesel fuel used to be in some sense a waste product and thus historically was cheaper than gasoline. It's only been within last 5 years or so that diesel has been consistently more expensive than gasoline, at least in the US.