FWIW: I've used both IE9 and IE10 at Khan Academy and have not found a way to copy either the code window text or the text in the canvas console. With IE10 I find even webpages who explicitly use client side code (javascript) to access the clipboard are also not allowed to add anything to the clipboard. (I get a dialog that asks if I want to allow access, and even after saying Yes, there is nothing added to the clipboard that can be pasted...)
Paste operations work OK (when there is something already on the clipboard) , but Copy has been disabled by default (I don't know if there is a setting somewhere to change the default).
When I want to copy stuff from KA, I have to fire up Chrome.
I don't have Firefox, but here is something that may have bearing on your problem. If (while using Firefox) you copy some text from KA and paste it into Notepad, is the formatting lost there as well? If Notepad shows the correct formatting (which I have seen happen on other websites) then its not a Copy problem but more of a Paste problem, in that the receiving application tries to deal with the content that is being pasted. When you then Copy the text from Notepad, and paste that into the code area, is the format retained? (That was the solution to the 'other website's copy and paste problem - use Notepad as an intermediary step)
Good luck!
LFS