FTP is pretty tricky to get right in scripts - I have used expect before but it takes a lot of doing. Better to use iControl REST.
Use my iCR Python module and use the script below:
!/usr/bin/env python
from iCR import iCR
bigip = iCR("172.24.9.132","admin","admin")
Create new UCS
data = { "command": "save", "name": "myTestUCS"}
ucs = bigip.create("sys/ucs",data)
Move UCS to /shared/images
data = { "command": "run", "utilCmdArgs": "-c 'mv /var/local/ucs/myTestUCS.ucs /shared/images'"}
mv = bigip.create("util/bash",data)
Download UCS
download = bigip.download("myTestUCS.ucs")
Delete UCS from /shared/images
data = { "command": "run", "utilCmdArgs": "-c 'rm /shared/images/myTestUCS.ucs'"}
rm = bigip.create("util/bash",data)
I'm sure you can see the parts which you need to change for your own environment.