Changed retrieve-resource() to retrieve the resource as binary.