A method of encoding programmed in a controller in a device comprising the steps of: a. partitioning an image formed by pixels into blocks; b. separating the pixels in each of the blocks into groups; c. sharing grouping data among color components wherein the grouping data includes information about which groups pixels belong to; and d. encoding a block from the most significant bit plane to the least significant bit plane and in each bit plane, processing existing groups wherein processing the existing groups includes: a. if members of the group have different values within the current bit plane, the group is split into two, unless at least one of two conditions exist, the two conditions including a total number of groups reaching a maximum limit of the groups or the total number of members in the group falling below a minimum limit; b. if either of the two conditions become true, then refinement bits of members of the group are encoded as raw bits; c. otherwise if a split happens to a group, a value indicating the split is sent, followed by one bit indicating the refinement bit of the group members; otherwise a value indicating no split is sent, followed by the refinement bits of each group member, the group is split into two according to the refinement bits, and the split is applied to additional colors of the block. a. partitioning an image formed by pixels into blocks; b. separating the pixels in each of the blocks into groups; c. sharing grouping data among color components wherein the grouping data includes information about which groups pixels belong to; and d. encoding a block from the most significant bit plane to the least significant bit plane and in each bit plane, processing existing groups wherein processing the existing groups includes: a. if members of the group have different values within the current bit plane, the group is split into two, unless at least one of two conditions exist, the two conditions including a total number of groups reaching a maximum limit of the groups or the total number of members in the group falling below a minimum limit; b. if either of the two conditions become true, then refinement bits of members of the group are encoded as raw bits; c. otherwise if a split happens to a group, a value indicating the split is sent, followed by one bit indicating the refinement bit of the group members; otherwise a value indicating no split is sent, followed by the refinement bits of each group member, the group is split into two according to the refinement bits, and the split is applied to additional colors of the block. a. if members of the group have different values within the current bit plane, the group is split into two, unless at least one of two conditions exist, the two conditions including a total number of groups reaching a maximum limit of the groups or the total number of members in the group falling below a minimum limit; b. if either of the two conditions become true, then refinement bits of members of the group are encoded as raw bits; c. otherwise if a split happens to a group, a value indicating the split is sent, followed by one bit indicating the refinement bit of the group members; otherwise a value indicating no split is sent, followed by the refinement bits of each group member, the group is split into two according to the refinement bits, and the split is applied to additional colors of the block. <EOS>