if you want to save only the detected faces (not the whole image), try to crop the face using :
for (x,y,w,h) in faces :
crop_face = img[y:y+h, x:x+w]
then to save it use : cv2.imwrite(crop_face, path)
you'll need to specify the path where you want to save the images
you can use :
path = os.path.sep.join([output_dir, "{}.jpg".format(str(total).zfill(8))])
where total is a counter to increment after each face detected, output_dir is the path of the folder where you want to save the images. generated images will count up incrementally from output_dir/00000000.jpg