message: Return a copy of the container buffer if the internal representation
  is not `Vec<u8>`.
diff: @@ -699,7 +699,9 @@ impl DynamicImage {
  image_as_bytes(self)
  }
  - /// Return this image's pixels as a byte vector.
  + /// Return this image's pixels as a byte vector. If the `ImageBuffer`
  + /// container is `Vec<u8>`, this operation is free. Otherwise, a copy
  + /// is returned.
  pub fn into_bytes(self) -> Vec<u8> {
  image_into_bytes(self)
  }
  @@ -1188,15 +1190,6 @@ fn image_to_bytes(image: &DynamicImage) -> Vec<u8> {
  }
  fn image_into_bytes(image: DynamicImage) -> Vec<u8> {
  - fn cast_vec(mut src: Vec<u16>) -> Vec<u8> {
  - unsafe {
  - let len = 2 * src.len();
  - let cap = 2 * src.capacity();
  - let ptr = src.as_mut_ptr();
  - std::mem::forget(src);
  - Vec::from_raw_parts(ptr as *mut u8, len, cap)
  - }
  - }
  match image {
  DynamicImage::ImageLuma8(a) => a.into_raw(),
  DynamicImage::ImageLumaA8(a) => a.into_raw(),
  @@ -1204,10 +1197,10 @@ fn image_into_bytes(image: DynamicImage) -> Vec<u8> {
  DynamicImage::ImageRgba8(a) => a.into_raw(),
  DynamicImage::ImageBgr8(a) => a.into_raw(),
  DynamicImage::ImageBgra8(a) => a.into_raw(),
  - DynamicImage::ImageLuma16(a) => cast_vec(a.into_raw()),
  - DynamicImage::ImageLumaA16(a) => cast_vec(a.into_raw()),
  - DynamicImage::ImageRgb16(a) => cast_vec(a.into_raw()),
  - DynamicImage::ImageRgba16(a) => cast_vec(a.into_raw()),
  + DynamicImage::ImageLuma16(_) => image.to_bytes(),
  + DynamicImage::ImageLumaA16(_) => image.to_bytes(),
  + DynamicImage::ImageRgb16(_) => image.to_bytes(),
  + DynamicImage::ImageRgba16(_) => image.to_bytes(),
  }
  }
  