An experimental and computational investigation of the space-charge effects occurring in ultrafast photoelectron spectroscopy from the gas phase is presented. The target sample CF$_3$I is excited by ultrashort (100 fs) far-ultraviolet radiation pulses produced by a free-electron laser. The modification of the energy distribution of the photoelectrons, i.e. the shift and broadening of the spectral structures, is monitored as a function of the pulse intensity. The experimental results are compared with computational simulations which employ a Barnes-Hut algorithm to calculate the effect of individual Coulomb forces acting among the particles. In the presented model, a survey spectrum acquired at low radiation fluence is used to determine the initial energy distribution of the electrons after the photoemission event. The spectrum modified by the space-charge effects is then reproduced by $N$-body calculations that simulate the dynamics of the photoelectrons subject to the individual mutual Coulomb repulsion and to the attractive force of the positive ions. The employed numerical method accounts for the space-charge effects on the energy distribution and allows to reproduce the complete photoelectron spectrum and not just a specific photoemission structure. The simulations also provide information on the time evolution of the space-charge effects on the picosecond scale. Differences with the case of photoemission from solid samples are highlighted and discussed. The presented simulation procedure, although it omits the analysis of angular distribution, constitutes an effective simplified model that allows to predict and account for space-charge effects on the photoelectron energy spectrum in time-resolved photoemission experiments with high-intensity pulsed sources.