Search MSDN for the string "Storing an image". It's a complete sample there.