Ab initio molecular dynamics, in which finite temperature molecular dynamics is performed with forces obtained from "on the fly" electronic structure calculations, is one of the most widely used theoretical tools for studying chemically active systems. Here, a significant step is taken to improve the efficiency, scaling with system size, and parallel efficiency of these calculations by the use of simple, localized, orthonormal real-space basis functions in conjunction with a unified reciprocal-space treatment of long-range interactions for various boundary conditions. This approach, which is capable of treating systems with zero-, one-, two-, or three-dimensional periodicity within a single framework, is shown to improve the convergence of total energies and forces by over an order of magnitude in grid size compared to the more commonly used plane-wave basis. Possibilities for employing the approach in a linear scaling method are briefly discussed.