add logic to decode optimized image