Conventional x-ray detectors integrate the photon energy flux, losing individual photon energy information. By contrast, energy resolved photon-counting x-ray detectors (PCXDs) count photons in energy windows, thus retaining some energy information. This provides a number of advantages, including the use of energy information to aid in material discrimination. However, this capability relies on accurately measuring changes in the energy spectrum as the x-ray beam passes through the object. Several effects, including characteristic x-ray effects and charge sharing between detector pixels, result in distortions in the energy spectrum that complicate measuring the attenuating effects of the object on the energy spectrum. Our goal was to investigate and develop models for these effects that would be useful in compensating for them in applications involving spectral analysis. We used a previously developed 6-threshold CdTe-based PCXD to validate the models. Previously with this detector we observed higher than predicted counts at low energies. Characteristic x-rays emitted in the detector can distort the spectrum in a pixel via x-ray escape either out of the detector or into adjacent pixels, giving rise to a count with a reduced energy. The escaped x-rays can also produce reduced-energy counts in adjacent pixels. The second effect, charge sharing, results since x-ray interactions in the detector produce a charge cloud with finite size. If close to a pixel boundary and combined with charge diffusion, reduced-energy counts in both pixels can be produced. In this study, we developed a fast Monte Carlo method for modeling characteristic x-ray effects and an analytic method for modeling charge sharing effects. The models produced energy spectra in good agreement with those measured by the PCXD. These models can be used to improve the performance of energy-based composition estimation and ring correction methods by modeling the spectral distortions present in real detectors.