Refactored image to array util.