1. A computer-implemented method for calculating an image, the method comprising: receiving a first electron-beam (EB) image of a pattern, wherein the first EB image is associated with an EB system; generating a multi-valued representation of the first EB image; and calculating, using the computer, a second EB image based on the multi-valued representation of the first EB image and a model of an electro-optical transfer function associated with the EB system, wherein the second EB image is calculated using an inverse calculation in which the multi-valued representation of the first EB image is at an image plane in the model of the electro-optical transfer function and the second EB image is at an object plane in the model of the electro-optical transfer function.