Fixed some errors and still having troubles outputting the rendered image