This is how I did this. From the Script Assertion of the http GET request. Hope It helps someone.
def ins = context.httpResponse.getRawResponseBody();
def isImageSaved = false;
InputStream inputStream;
FileOutputStream outputStream;
if (ins){
try {
inputStream = new ByteArrayInputStream(ins);
outputStream = new FileOutputStream(new File(context.expand("C:\\animal.jpg")));
int read = 0;
byte[] bytes = new byte[1024];
while ((read = inputStream.read(bytes)) != -1) {
outputStream.write(bytes, 0, read);
}
isImageSaved = true;
}catch (Exception e){
log.error e;
e.printStackTrace();
}finally{
inputStream.close();
outputStream.close();
}
} else {
log.error "image does not exist...";
}
context.testCase.setPropertyValue("isImageSaved", isImageSaved.inspect());