Implement encode and decode of image string.