Optical imaging systems are used extensively in the life and physical sciences because of their ability to non-invasively capture details on the microscopic and nanoscopic scales. Such systems are often limited by source or detector noise, image distortions and human operator misjudgement. Here, we report a general, quantitative method to analyse and correct these errors. We use this method to identify and correct optical aberrations in an imaging system for single atoms and realize an atomic position sensitivity of -0.5 nm Hz(-1/2) with a minimum uncertainty of 1.7 nm, allowing the direct imaging of atomic motion. This is the highest position sensitivity ever measured for an isolated atom and opens up the possibility of performing out-of-focus three-dimensional particle tracking, imaging of atoms in three-dimensional optical lattices or sensing forces at the yoctonewton (10(-24) N) scale.