convert resource to binary