How do I set default group ownership for files in a directory?

To assign group ownership by www-data regardless of the uid/gid of the process that creates the file, you need to set the setgid bit on the directory.

    sudo chown :www-data <dir>
    sudo chmod g+s <dir>

Note that you must also make the directory writable by whatever process will create the files. If that's anyone but root, you may also need chmod o+rwx to get things working properly.