I'd start by using Activity Monitor to read System Memory and determine how much RAM is being used to see if your machine has an adequate amount of RAM for your needs. Also use Finder to determine how much free HD space you have. For your wi-fi issues, update both your router and modem to the most up-to-date firmware then restart and test.
You haven't provided much useful information other that what version of OS X you are using. What apps are running, which iMac do you have, etc...
It's likely the slow running and flaky wifi are two separate issues.
For the slow running, and just to rule out some known causes, are you running any anti-virus program - Norton, MacKeeper, Kaspersky, etc?
For the wifi issue here are some suggestions - wifi issues seem to crop up a lot on here and unfortunately there doesn't seem to be a 'one fix' solution.
However, sometimes any one of the following can help although, unfortunately, not always - in no particular order:
- Check wifi security - if it's WEP change it to WPA or WPA2 (preferably, as it's more secure)
- Change the wifi channel on the router
- Create a new Network Location: http://support.apple.com/kb/HT5289
- Reboot the router
Also take a look at this link and the links within the article for other ideas. They mainly reference Lion, but still seem to be relevant to Mountain Lion:
...and this link: