We are having problems with $CFG->pixpath in HEAD>
To start with, it is a nasty global variables hack.
But the problem is that you cannot set up $CFG->pixpath until the theme is known. But the theme is only know after a variety of other things are done and it is hard to predict when that is.
However, we do currently have clever code to initialise $OUTPUT the first time it is used.
Old code that used the string "$CFG->modpixpath/$cm->modname/icon.gif" should be updated to $OUTPUT->mod_icon_url('icon', $cm->modname);
Old code that used the string "$CFG->pixpath/i/settings.gif" should be updated to $OUTPUT->old_icon_url('i/settings');
The reason for the slightly ugly function names is what we are planning (http://moodle.org/mod/forum/discuss.php?d=126543) to change the default icon-set in Moodle. When that happens we will probably adopt new names for all the icons. At that point, I propose that we move to a function $OUTPUT->icon_url($icon, $module); where $module is like the same argument to get_string. That is, we let all types of plugins supply their own icons in future, not just modules.
Note that the API does not include the file extension. We should not hard-code this. Instead themes should be able to choose png or gif.
Also, eventually, icon_url should do a search of theme, parent theme, standard theme, like smartpix.php does.