  The electron-cyclotron maser instability is widespread in the Universe,
producing, e.g., radio emission of the magnetized planets and cool substellar
objects. Diagnosing the parameters of astrophysical radio sources requires
comprehensive nonlinear simulations of the radiation process. We simulate the
electron-cyclotron maser instability in a very low-beta plasma. The model used
takes into account the radiation escape from the source region and the particle
flow through this region. We developed a kinetic code to simulate the time
evolution of an electron distribution in a radio emission source. The model
includes the terms describing the particle injection to and escape from the
emission source region. The spatial escape of the emission from the source is
taken into account by using a finite amplification time. The unstable electron
distribution of the horseshoe type is considered. A number of simulations were
performed for different parameter sets typical of the magnetospheres of planets
and ultracool dwarfs. The generated emission (corresponding to the fundamental
extraordinary mode) has a frequency close to the electron cyclotron frequency
and propagates across the magnetic field. Shortly after the onset of a
simulation, the electron distribution reaches a quasi-stationary state. If the
emission source region is relatively small, the resulting electron distribution
is similar to that of the injected electrons; the emission intensity is low. In
larger sources, the electron distribution may become nearly flat due to the
wave-particle interaction, while the conversion efficiency of the particle
energy flux into waves reaches 10-20%. We found good agreement of our model
with the in situ observations in the source regions of auroral radio emissions
of the Earth and Saturn. The expected characteristics of the electron
distributions in the magnetospheres of ultracool dwarfs were obtained.
