Writing binary data, especially if you want to write out to several files, several objects, ... to disk is a bit of a pain. Your best bet would be to write a small application say in C# :).
If that is not an option, have a look at http://www.sqlservercentral.com/articles/Miscellaneous/writingtoafileusingthesp_oacreatestoredprocedurean/1694/
Regards,
Andras