bug fixes in c++ side

1. check if failed memory allocation
2. initialize baton's fields (this caused a major headache
   debugging why a jpeg compression sometimes randomly failed
   in windows - a batton's 'bufferSize' field was not initialized.)