You don't need to extend the Page_Controller. Just put it in your SiteConfigCustom class
class SiteConfigCustom extends DataExtension {
public function getRandomImage() {
return $this->BackgroundImages()->sort('RAND()')->First();
}
}
and as far as i know, in your template file (Page.ss) you have to put the $ sign when using <% loop %>
<% loop $SiteConfig %>
<% end_loop %>
It may not work without the $.