Your order of events is wrong..
first you must do this:
dllfunction render_backbuffer(entity);

then call screengrab();