/**
   * Writes a ColorImage to a file byteSizing first
   *
   * @param im the ColorImage
   */
  public void writeByteSized(ColorImage im) throws IOException {

    X = im.X();
    Y = im.Y();
    int[] color = new int[3];

    // convert to byte size
    ColorImage tmpim = (ColorImage) im.copy();
    tmpim.byteSize();

    // write PPM in raw format

    writeRawPPMHeader(X, Y);
    for (int y = 0; y < Y; y++) {
      for (int x = 0; x < X; x++) {
        color = tmpim.get(x, y);
        data.write((byte) color[0]);
        data.write((byte) color[1]);
        data.write((byte) color[2]);
      }
    }
  }