You posted way too much code. I didn't bother to look through it. Using google, I found this code in a CP article:
public byte[] ImageToByteArray( System.Drawing.Image p_ImageIn )
{
byte[] aRet = null;
using ( System.IO.MemoryStream oMS = new System.IO.MemoryStream() )
{
p_ImageIn.Save( oMS, System.Drawing.Imaging.ImageFormat.Gif );
aRet = oMS.ToArray();
}
return aRet;
}