fixed path/unicode errors when building the index

When we are called as a git hook we
 .) can not load the template from '.', since that would be the dir
    we are executed in (which is the bare git repo)
    We therefore have to use the scripts location to find the
    template file (at least currently, when used directly from git)
 .) We have to specify encoding explicitly when writing files since
    there is no locale set. Python/Linux defaults to Ascii in that
    case, leading to encoding errors that do not happen when executed
    in a 'proper' shell. The especially concerns the output of jinja
    templates and print() calls (also to stdout/stderr!).