altered the code a little so that saving the output image works. Did I mention C++ is a bitch?