Moved the image stream pipe logic further down.