Write to the flash, if failed return corresponding error. Signed-off-by: Adam Wujek <adam.wujek@cern.ch>