Call ob_clean to prevent corrupted images

When I tried to use the captcha as an url my images became corrupt. 

I'm not sure whether it is my installation, but cleaning the output buffer before starting fixed my issue.