  Context. The increase in sensitivity of Imaging Atmospheric Cherenkov
Telescopes (IACTs) has lead to numerous detections of extended $\gamma$-ray
sources at TeV energies, sometimes of sizes comparable to the instrument's
field of view (FoV). This creates a demand for advanced and flexible data
analysis methods, able to extract source information by utilising the photon
counts in the entire FoV.
  Aims. We present a new software package, "SkyPrism", aimed at performing 2D
(3D if energy is considered) fits of IACT data, possibly containing multiple
and extended sources, based on sky images binned in energy. Though the
development of this package was focused on the analysis of data collected with
the MAGIC telescopes, it can further be adapted to other instruments, such as
the future Cherenkov Telescope Array (CTA).
  Methods. We have developed a set of tools that, apart from sky images (count
maps), compute the instrument response functions (IRFs) of MAGIC (effective
exposure throughout the FoV, point spread function (PSF), energy resolution and
background shape), based on the input data, Monte-Carlo simulations and the
pointing track of the telescopes. With this information, the presented package
can perform a simultaneous maximum likelihood fit of source models of arbitrary
morphology to the sky images providing energy spectra, detection significances,
and upper limits.
  Results. We demonstrate that the SkyPrism tool accurately reconstructs the
MAGIC PSF, on and off-axis performance as well as the underlying background. We
further show that for a point source analysis with MAGIC's default
observational settings, SkyPrism gives results compatible with those of the
standard tools while being more flexible and widely applicable.
