It turns out that electric cars are even better than that. The Union of Concerned Scientists writes that even if battery-electric vehicles "are recharged with electricity from power plants that use fossil fuels, they are up to 99 percent cleaner than conventional vehicles and can cut global warming emissions by as much as 70 percent." Apparently electric cars only produce carbon emissions on par with gasoline cars if you use entirely coal-based electricity to power them. (Coal is really bad, since it's almost entirely carbon. Natural gas has more hydrogen, which burns into water.)
Part of the reason is that car engines are a lot less efficient at turning fuel into motion than power plants. It's one of the trade-offs you'd expect in designing small portable things like cars as opposed to big stationary things like power plants. Power plants can be built to capture every last bit of energy, while cars have to meet a bunch of other design constraints or they won't go.