You have to set HttpListenerResponse.ContentType to the appropriate MIME type for the image, such as "image/gif".
In addition, the example code is reading the image through a TextReader and converting it to a UTF8 byte array. That's not going to work for binary files; it'll mangle the bytes. You need to read those files with a FileStream or any other approach that will return the binary file contents unmodified.