I have a custom class and made the same serialization as System.Drawing.Image, by implementing ISerializable interface and two methods: