Replace tee
with a function that creates the directory for you:
tee() { mkdir -p ${1%/*} && command tee "$@"; }
If you want the function to work when invoked with a simple file name:
tee() { if test "$1" != "${1%/*}"; then mkdir -p ${1%/*}; fi && command tee "$1"; }