Fixed memory leak and cached Graphviz context

There is no need to create and destroy the context every time.
The returned pointer to char used to leak; now we save the last
result and free it before returning the next one.
Fixed agraphattr_init emscripten invalid cast warning