The problem with this isn't so much that it is insecure to log in as www-data but that it is insecure to have your entire website writable by that account. You should use another account for managing your website files which has write permissions to the directories. That user should own the files (and is generally also in the www-data group but this isn't absolutely needed). You will then be able to set the permissions you need by using the group permissions to specify what the website can do and user permissions to specify what your management account can do. You probably won't ever need to give any permissions to others for these files.
This management account should also be able to sudo chmod (and probably sudo chown) those files as needed in order to allow the website write permissions on specific folders in your site (such as a temp folder). If you do not want to allow that by this user then you'll need to provide folders for this purpose that you require website managers to use.
Edit: You can also remove read permission on files to remove them from the website without deleting them. This is a little less safe to do though because you may accidentally set it back without knowing when you upload it next time. This is why I would also suggest always writing a publish script to automate uploading your files and doing these sort of changes so they are never forgotten.