The problem of reconstructing incident radiotherapy beam profiles from electronic portal images recorded behind a phantom is addressed. To this end an iterative algorithm is presented, which is able to extract the input beam profile from a portal image by compensating for the attenuation of the beam and subtracting the amount of scatter emitted by the phantom. The algorithm requires only a thickness map of the phantom. Scatter is estimated using a superposition method based on precalculated Monte Carlo scatter kernels. The method is tested for a homogeneous water-equivalent slab phantom for simple rectangular and complex multileaf collimated fields. It is shown that the method produces a stable result within four iterations yielding an accuracy for the incident beam distribution of better than 3%.