Image encoding and decoding working for png images