I don't think you can do paid work and stipulate whether the they can later sell it to anyone. If you can learn something from this, it should be that next time you might be able to cut out the middle man.
You can contract just about any terms you like, including retention of copyright and limitations on the license granted. Don't just accept whatever terms someone predatory offers to you. (software consultant, not a lawyer)
Accepting a contract on elance doesn't let you set these kind of terms. It's pure work for hire, or you wouldn't get the job.
You could try, but I was arguing you won't have much luck with that. Not many people will hire you if there are specific strings attached to what you produce.