added save_with_compression(output, ratio) to control jpeg compression