def METHOD_NAME(cssfile, rootdirs):
    csspath, fname = os.path.split(cssfile)
    with codecs.open(cssfile, encoding='utf-8') as fp:
        css = fp.read()
        cssparse = re.compile(r'(.*?){([^}]+)}', re.S)
        urlparse = re.compile(r'url\(([^\)]+)\)')
        cssout = []
        for selector, content in cssparse.findall(css):
            for url in urlparse.findall(content):
                if not url.strip("\"'").startswith('data:'):
                    imgpath = _resolve_path(os.path.join(csspath, url.strip("\"'")), rootdirs)
                    content = re.sub(url, serve.make_base64(imgpath).replace('\n', ''), content)
            cssout.append(u"%s {\n%s\n}"%(selector, content))
        return '\n'.join(cssout)