see "understanding tee" in the first answer here:

http://stackoverflow.com/questions/2600783/how-does-the-vim-write-with-sudo-trick-work