private static void writeLeftAlignedValue(FileImageOutputStream stream,
                                            TiffType type, int val)
                                           throws IOException {
    switch (type) {
    case SHORT:
      stream.writeShort(val);
      stream.writeShort(0);
      break;
    case LONG:
      stream.writeInt(val);
      break;
    default:  // There are other possible types, but we're not using them.
      throw new IllegalArgumentException();
    }
  }