Fix assumption that all screen templates start with <?php. Also fix encoding when writing to template cache file.