Updated function documentation.
Added write_img function.