Using the iMac's own DAC and its headphone jack is not going to produce hifi sound, but on the other hand, for out-of-the-box computer sound, that G4 sounds darn good. You should not be experiencing any overt distortion like you describe.
Please try one thing: Play some of your music files through QuickTime on your iMac (don't even launch iTunes). If the music sounds clean when played through QT, you have a software issue that I may be able to help you with.
Please try one thing: Play some of your music files through QuickTime on your iMac (don't even launch iTunes). If the music sounds clean when played through QT, you have a software issue that I may be able to help you with.