"'The software needed (for) the 'USB Flash Disk' cannot be found. Please refer to the device documentation to install the necessary software.' Same thing happens when I try to connect an external hard drive."
The compatibility of USB-connected peripherals depends on the OS version that your iMac is running, because this determines the version of the USB Mass Storage Support files installed with the OS. For a flash drive to be recognized and function properly, you need to be running at least OS 9.1, because the database of supported devices was much broader than with previous versions.
"I have also tried to copy files to a CD but the message I get when I try to initialize the disk is: Disk initialization failed because the disk is locked!"
Were you attempting to write to a blank disk in a USB-connected CD-R/RW drive, and if so, what manufacturer's name is on the drive? Unsupported brands/models won't be recognized by an iMac running a pre-OS X version of the Mac OS, because the "Authoring Support" files were written for burners in existence at that time. I always preferred using "Roxio's Toast 5.x" for disk burning, rather than Apple's native DiskBurner program.
Because the solution to your problem may take several more posts from you, as you provide additional information and specific feedback for suggestions made, it's better to not have your topic buried within someone else's year-old, "Solved" topic.