The problem with writing to the plist is that it isn't picked up until reboot... this was less than ideal. The solution I found is actually with Applescript! Using Applescript causes the system to be aware of the change unlike using defaults.
Here's a summarized snippet of a script I have that is the meat of what you want to do...
The checks for time are essential, if the time is set to something other than what the GUI allows if will just change it to 20min when you check the GUI - and leave you scratching your head (as it did me!).
#!/bin/bash
idleTimeMinutes=$4
if [ "$idleTimeMinutes" -ne 1 -a "$idleTimeMinutes" -ne 2 -a "$idleTimeMinutes" -ne 5 -a "$idleTimeMinutes" -ne 10 -a "$idleTimeMinutes" -ne 20 -a "$idleTimeMinutes" -ne 30 -a "$idleTimeMinutes" -ne 60 ]; then
echo "Time in minutes MUST BE: 1, 2, 5, 10, 20, 30, or 60"
exit
else
idleTimeSeconds=$(( $idleTimeMinutes * 60 ))
fi
eval $(stat -s /dev/console)
consoleUID=$st_uid
consoleUsername=$(id -un $st_uid)
if [ "$consoleUID" -eq 0 ]; then
echo "No console user (login screen), exiting"
exit
fi
su $consoleUsername <<-EOS
osascript -e 'tell application "System Events" to set delay interval of screen saver preferences to '$idleTimeSeconds''
EOS