Control of nanoparticle dispersion in thin polymer films