def method2format(output, _format="png", mx=None, raw=None):
    """
    Export method to a specific file format

    @param output : output filename
    @param _format : format type (png, jpg ...) (default : png)
    @param mx : specify the MethodAnalysis object
    @param raw : use directly a dot raw buffer if None
    """
    # pydot is optional!
    import pydot

    buff = "digraph {\n"
    buff += "graph [rankdir=TB]\n"
    buff += "node [shape=plaintext]\n"

    if raw:
        data = raw
    else:
        data = method2dot(mx)

    # subgraphs cluster
    buff += "subgraph cluster_{} ".format(hashlib.md5(bytearray(output, "UTF-8")).hexdigest())
    buff += "{\n"
    buff += "label=\"{}\"\n".format(data['name'])
    buff += data['nodes']
    buff += "}\n"

    # subgraphs edges
    buff += data['edges']
    buff += "}\n"

    d = pydot.graph_from_dot_data(buff)
    if d:
        for g in d:
            getattr(g, "write_" + _format.lower())(output)
Export method to a specific file format

    @param output : output filename
    @param _format : format type (png, jpg ...) (default : png)
    @param mx : specify the MethodAnalysis object
    @param raw : use directly a dot raw buffer if None